//
//  LeCameraManager.cpp
//  Leste
//
//  Created by 王乐 on 2022/1/25.
//

#include "LeCameraManager.h"
#include "LeCameraBaseBehaviour.h"

LeCameraObject* LeCameraManager::pCameraObject = nullptr;

LeCameraManager::LeCameraManager() { 
    
}

LeCameraManager::~LeCameraManager() { 
    
}

void LeCameraManager::initMainCamera(LeCameraObject* pcameraobj)
{
    pCameraObject = pcameraobj;
}

glm::mat4 LeCameraManager::getViewMatrix()
{
    return dynamic_cast<LeCameraBaseBehaviour*>(pCameraObject->m_pBehaviour)->getViewMatrix();
}

glm::mat4 LeCameraManager::getProjectionMatrix()
{
    return dynamic_cast<LeCameraBaseBehaviour*>(pCameraObject->m_pBehaviour)->getProjectionMatrix();
}

glm::vec3 LeCameraManager::getCameraPosition()
{
    return pCameraObject->m_Transform.m_Position;
}

void LeCameraManager::setCameraTarget(LeGameObject *ptarget)
{
    if(pCameraObject != nullptr)
    {
        dynamic_cast<LeCameraBaseBehaviour*>(pCameraObject->m_pBehaviour)->setCameraTarget(ptarget);
    }
}

void LeCameraManager::setCameraShakeMode(bool shake)
{
    if(pCameraObject != nullptr)
    {
        dynamic_cast<LeCameraBaseBehaviour*>(pCameraObject->m_pBehaviour)->setCameraShakeMode(shake);
    }
}
